// widgets/User/UserOrderWidget/UserOrderWidget.js
//获取应用实例
const app = getApp();
const assetsAddress = app.globalData.global.assetsIp + '/' + app.globalData.global.assetsName;
Component({

    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
      navList: [
        { id: '1', name: '已预约', icon: assetsAddress + '/user/haveAlreadyIcon.png', path: '/pages/Order/ServiceOrder/ServiceOrder'},
        { id: '3', name: '已完成', icon: assetsAddress + '/user/completedIcon.png', path: '/pages/Order/ServiceOrder/ServiceOrder'},
        { id: '2', name: '取消/售后', icon: assetsAddress + '/user/cancelIcon.png', path: '/pages/Order/ServiceOrder/ServiceOrder'},
      ],
    },

    /**
     * 组件的方法列表
     */
    methods: {
      // 全部订单
      allOrder(){
        wx.navigateTo({
          url: '/pages/Order/ServiceOrder/ServiceOrder',
        })
      },
      // 页面跳转
      goNext(e){
        let type = e.target.dataset.type||e.currentTarget.dataset.type;
        let url = e.target.dataset.name||e.currentTarget.dataset.name;
        let item = e.target.dataset.item||e.currentTarget.dataset.item;
        // console.log(JSON.stringify(item))
        // return
        if(item){
          if(type == 1){
            wx.switchTab({
              url: `${url}`,
            })
          }else{
            wx.navigateTo({
              url: `${url}?item=${JSON.stringify(item)}`,
            })
          }
        }else{
          if(type == 1){
            wx.switchTab({
              url: `${url}`,
            })
          }else{
            wx.navigateTo({
              url: `${url}`,
            })
          }
        }
      },
    }
})